package com.itheima.mapper;

import com.itheima.pojo.Spec;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SpecMapper extends Mapper<Spec> {

    @Select("SELECT spec_id FROM tb_category_spec WHERE category_id = #{category3id}")
    public List<Integer> findSpecIdsByCategoryId(Integer category3id);

    @Insert("insert into tb_spec values(null, #{name}, #{options}, #{seq})")
    Integer handleAdd(Spec spec);

    @Delete("delete from tb_spec where id = #{id}")
    Integer handleDelete(Integer id);

    @Select("select * from tb_spec where id = #{id}")
    Spec findById(Integer id);

    @Update("update tb_spec set name = #{name}, options = #{options}, seq = #{seq} where id = #{id}")
    Integer update(Spec spec);
}
